﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using XZL.GM.Bll;

public partial class Account_AccountInfo : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            txtAccountStart.Text=DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");
            txtAccountEnd.Text=DateTime.Now.ToString("yyyy-MM-dd");
            BindAccountTypeList();
            BindAccountList();
            
        }
    }


    private void BindAccountList()
    {
        DateTime accountStart = new DateTime();
        DateTime accountEnd = new DateTime();

        try
        {
            accountStart=Convert.ToDateTime(txtAccountStart.Text);
            accountEnd=Convert.ToDateTime(txtAccountEnd.Text);
            accountEnd=accountEnd.AddDays(1);
        }
       catch(Exception ex)
        {
            lblWarn.Text = "请输入正确的日期格式！";
            return;      
        }
         int? count = 0;

        string orderID = txtOrderID.Text.Trim();

        string nickName=txtNickName.Text.Trim();
        int accountType = Convert.ToInt32(ldlAccountType.SelectedValue);
        int payType = Convert.ToInt32(ddlPayType.SelectedValue);
        // divCondition.Visible = true;
        gridList.DataSource = AccountInfo.GetAccountList(accountStart,accountEnd,orderID,nickName,accountType,payType, netPager.CurrentPageIndex, netPager.PageSize, ref count);
        gridList.DataBind();
        netPager.RecordCount = count.Value;


    }


    protected string DGFormatSex(string PayType)
    {
        if (PayType == "1")
        { return "微信支付"; }

        else if (PayType == "2")
        { return "账户余额"; }

        else if (PayType == "3")
        { return "积分"; }

        return "";
    }


    private void BindAccountTypeList()
    {
        ldlAccountType.DataSource = AccountInfo.GetAccountTypeList();
        ldlAccountType.DataValueField = "AccountTypeID";
        ldlAccountType.DataTextField = "AccountTypeName";
        ldlAccountType.DataBind();
       // ldlAccountType.Items.Insert(0, new ListItem("全部", "0"));
    }

    /// <summary>
    /// 分页控件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    /// 
    protected void netPager_PageChanged(object sender, EventArgs e)
    {
        BindAccountList();
    }

    protected void btnSelect_Click(object sender, EventArgs e)
    {
        BindAccountList();
        netPager.CurrentPageIndex = 1;
    }

}